#!/bin/bash
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: extractapk.sh
# Description: 
# 
# Edit History: 
#   2011-07-20    File created.
#===============================================================================
APKTOOL="$HOME/apktool/apktool"

#解開所有apk,並紀錄每個apk解開的資訊
find . -name "*.apk" -maxdepth 1 -exec echo "{} is extracting now!" \; -exec $APKTOOL d {} \; 2>&1 | tee extract.log 

#取出所有apk的AndroidManifest.xml觀察
find . -name AndroidManifest.xml -maxdepth 2 -exec echo {} \; -exec cat {} \;  > observed.xml

#列出所有apktool d 失敗的目錄
echo "" >failapk;
for dir in ./*/
do
	if [ ! -e $dir/AndroidManifest.xml ] ; then
		echo $dir >> failapk ;
	fi
done

